<%--
 *  File:    InstanceUserGroupSummary.jsp
 *  @Author: Saraxia 
 *  Date:    2012/11/06
 *
 *  Copyright (C) 2000 - 2001 Oval Technologies, Inc.
 *  All rights reserved. 
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval. 
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>     
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>

<% //--------------------------------------  setting logger --%>
<%
  	Category cat = Category.getInstance("jsp.InstanceUserGroupSummary"); 
%>

<% //--------------------------------------  variant and initialization --%>
<%
	String strModuleName = "COM";
  	String strTableName = "ovinstanceusergroup";
  	String privilegeCode = "Z0103,L402";
%>



<%
  	HashMap CurUserInfo = (HashMap)session.getAttribute("userinfo");
  	String isPrimaryAdmin = (String)CurUserInfo.get("isprimaryadmin");
  	Integer nCurUserId = (Integer)CurUserInfo.get("zylmdapprovalgroupid");
  	if(isPrimaryAdmin == null)
  	{
    	isPrimaryAdmin = "";
  	}
%>

<% //--------------------------------------  include files list --%>
<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>


<html>
<head>
<title>InstanceUserGroupSummary</title>
<PageFlow:CheckPageFlow pageName="instanceusergroupsummary"/>
<%@ include file="/inc/InitEdit.inc" %>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="../../css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="../../js/FuncLib.js"></script>
<%@ include file="/inc/SummaryDivision.inc" %>
<script>
parent.down.location.href = "Blank.jsp?<%= OvalTools.randomURL() %>";
function radiotrue0(elem0)
{
	var frm = document.usergroupsummaryform;
	for(i=0;i<frm.elements.length;i++){
		var elem = frm.elements[i];
		if(elem.type=='radio' & elem.id==elem0)
			if(!elem.disabled)
				radiotrue(elem0);
	}
}

function clickUserGroup(id)
{
  parent.down.location.href = "Blank.jsp?<%= OvalTools.randomURL() %>";
  document.usergroupsummaryform.zylmdapprovalgroupid.value = id;
}
function page_delete()
{
  var id = document.usergroupsummaryform.zylmdapprovalgroupid.value;
  
  if(id == null || id.length == 0 || id == "" || id == "-1")
    return;
    
   if(id == "<%=JspHelper.filterNull( nCurUserId )%>")
  {
    alert("<%= message.getMessageDesc("CAN_NOT_DEL_IT") %>");
    return;
  }
  var flag = confirm("<%= message.getMessageDesc("ARE_YOU_SURE_DEL") %>");
  if(!flag)
    return;
  document.usergroupsummaryform.actionname.value = "delete";
  isRunning = true;
  document.usergroupsummaryform.submit();
}
function page_edit()
{
  	var uid = document.usergroupsummaryform.zylmdapprovalgroupid.value;
  	if(uid == null || uid.length == 0 || uid == "" || uid == "-1")
    	return;
    
  	var frm = document.usergroupsummaryform;
	for(i=0;i<frm.elements.length;i++){
		var elem = frm.elements[i];
		if(elem.type=='radio' & elem.value==uid)
			if(elem.disabled)
			{
				return;
			}
	}
	
  	parent.down.location.href = "InstanceUserGroupEdit.jsp?<%= OvalTools.randomURL() %>&zylmdapprovalgroupid=" + uid + "&languagecode=<%= strLanguageCode %>";
}
function page_summary(actionvalue,orderbyname)
{
  var editform = summaryPrepare(usergroupsummaryform,actionvalue,orderbyname);
  editform.action = "InstanceUserGroupSummary.jsp?<%= OvalTools.randomURL() %>";
  editform.target = "_self";
  isRunning = true;
  editform.submit();  
}

function page_deptedit()
{
  if ( document.usergroupsummaryform.editflag.value=='Disabled')
      return;
  var url='../../zstf/img/ZSTFUserDeptSummary.jsp?<%= OvalTools.randomURL() %>&zylmdapprovalgroupid='+usergroupsummaryform.zylmdapprovalgroupid.value+'&mdapprovalgroupname='+usergroupsummaryform.mdapprovalgroupname.value;
  parent.down.location.href=url;
}
</script>

<% //--------------------------------------  output variant from pageflow --%>
<%
  	Vector userGroupSummary = (Vector)pageContext.getAttribute("ugsummary");
  	if(userGroupSummary == null)
  	{
    	userGroupSummary = new Vector();
  	}
%>
</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

	<% //--------------------------------------  hidden form variant --%>
	<form name="usergroupsummaryform" method="post" action="../../Dispatcher"  target="_parent">
    <input type="hidden" name="pagename" value="instanceusergroupsummary">
    <input type="hidden" name="actionname">
    <input type="hidden" name="languagecode" value="<%= strLanguageCode %>">
    
	<% //--------------------------------------  page location --%>
	<%@ include file="/inc/PageLocation.inc" %>
	
	<table width="100%" cellspacing="0" cellpadding="0" border="0">
  	<tr> 
    	<td valign="top"> 
    		<table width="100%" border="0" cellspacing="0">
          	<tr><td class="summary_top" ></td></tr>
        	</table>
        	<table width="100%" border="0" cellspacing="0" cellpadding="0">
				<%@ include file="/inc/SummarySearch.inc" %>
        	</table>
        </td>
   	</tr>
   	</table>
   
   	<table border="1" cellspacing="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" align="center" width="100%" cellpadding="0">
   
   	<% //--------------------------------------  summary header --%>
   	<tr bgcolor="#ACBCCA"  class="deepblue-left" > 
   		<td width="5%" class="title_center" >&nbsp;</td>
       	<td width="34%" class="title_center" ><a href="javascript:page_summary('orderby','mdapprovalgroupname')"><%= label.getLabelName("L_UserGroupName") %></a></td>
       	<td class="title_center" ><a href="javascript:page_summary('orderby','description')"><%= label.getLabelName("L_description") %></a></td>
       	<td width="11%" class="title_center" ><a href="javascript:page_summary('orderby','statusname')"><%= label.getLabelName("L_Status") %></a></td>
    </tr>

	<% //--------------------------------------  default value definition --%>
    <%
        Integer nDefaultzylmdapprovalgroupid = new Integer(-1);               
        String strClassType = new String(); 
        boolean bHasChecked = false;
        String strDefaultIsDisabled="";
        String strDefaultmdapprovalgroupname=""; 
   	%>
   	
    <% //--------------------------------------  loop results --%>
    <logic:iterate id="usergroup" collection="<%= userGroupSummary %>" indexId="orderId">                      
    	
    <%
    	HashMap userGroupMap = (HashMap)pageContext.getAttribute("usergroup"); 
        String ugName = (String)userGroupMap.get("mdapprovalgroupname");
        String strIsDisabled = "";
        String strIsChecked = "";
            
        if((orderId.intValue())%2 == 1){
        	strClassType = "td-listrom";             
        }else{                    
            strClassType = "none";
        }
        
        if(ugName.equalsIgnoreCase("everyone") || ugName.equalsIgnoreCase("administrator"))
        {
        	strIsDisabled = new String(" Disabled ");             
        } 
        else if(!bHasChecked)
        {
	        strIsChecked = "Checked";                       
            bHasChecked = true;
            nDefaultzylmdapprovalgroupid = (Integer)(userGroupMap.get("zylmdapprovalgroupid"));
            strDefaultmdapprovalgroupname= (String)(userGroupMap.get("mdapprovalgroupname"));    
          	strDefaultIsDisabled = strIsDisabled;            
        }                
  	%>
    
    <tr onMouseOver="this.className='tr-over'" onMouseOut="this.className='<%=JspHelper.filterNull( strClassType )%>'" <%if(strIsDisabled.length()==0){%> onClick="javascript:radiotrue0('usergroup<%=JspHelper.filterNull( orderId )%>');clickUserGroup('<%=JspHelper.filterNull( userGroupMap.get("zylmdapprovalgroupid") )%>');"<%}%> class="<%=JspHelper.filterNull( strClassType )%>">
    	<td width="5%" class="<%=JspHelper.filterNull( strClassType )%>">
        	<input id="usergroup<%=JspHelper.filterNull( orderId )%>" type="radio" name="zylmdapprovalgroupids" <%=JspHelper.filterNull( strIsDisabled )%> value=<%=JspHelper.filterNull( userGroupMap.get("zylmdapprovalgroupid") )%> class="normalradio" <%=JspHelper.filterNull( strIsChecked)%> <%if(strIsDisabled.length()==0){%> onClick="javascript:clickUserGroup('<%=JspHelper.filterNull( userGroupMap.get("zylmdapprovalgroupid") )%>')"<%}%>>
        </td>
        <td width="34%" class="<%=JspHelper.filterNull( strClassType )%>">&nbsp;<a href="InstanceUserGroupDetail.jsp?<%= OvalTools.randomURL() %>&zylmdapprovalgroupid=<%=JspHelper.filterNull( userGroupMap.get("zylmdapprovalgroupid") )%>&mdapprovalgroupname=<%=JspHelper.filterNull( userGroupMap.get("mdapprovalgroupname") )%>" target="down"><%=JspHelper.filterNull( userGroupMap.get("mdapprovalgroupname") )%></td>
        <td class="<%=JspHelper.filterNull( strClassType )%>">&nbsp;<%=JspHelper.filterNull( userGroupMap.get("description") )%></td>
        <td width="11%" class="<%=JspHelper.filterNull( strClassType )%>">&nbsp;<%=JspHelper.filterNull( userGroupMap.get("statusname") )%></td>
    </tr>
    </logic:iterate>  
    
    <% //--------------------------------------  default value --%>       
    <input type="hidden" name="zylmdapprovalgroupid" value="<%=JspHelper.filterNull( nDefaultzylmdapprovalgroupid )%>">
    <input type="hidden" name="mdapprovalgroupname" value="<%=JspHelper.filterNull( strDefaultmdapprovalgroupname )%>">  
    <input type="hidden" name="editflag" value="<%=JspHelper.filterNull( strDefaultIsDisabled )%>">
          
    <% //--------------------------------------  flipping page --%>
    <%@ include file="/inc/SummaryAction.inc" %>
    </table>
    
    <% //--------------------------------------  page operation button --%>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    	<tr> 
        	<td class="summary_top" ></td>
        </tr>
		<%if(privilegeSet != null && privilegeSet.contains("B6040")){%>  
        <tr> 
        	<td class="td_center"> 
        		<a onclick="parent.down.location.href='InstanceUserGroupEdit.jsp?<%= OvalTools.randomURL() %>';"><custom:button type="1" label="L_New" imgsrc="new.gif" border="0" style="width:60"/></a>
        		<a onclick="page_edit()"><custom:button type="1" label="L_Edit" imgsrc="edit.gif" border="0" style="width:60"/></a>
        		<a onclick="page_delete()"><custom:button type="1" label="L_Delete" imgsrc="delete.gif" border="0" style="width:60"/></a>        		
        	</td>
        </tr>
		<% } %>
  	</table>

   	</td>
</tr>
</table>
</form>
</body>
</html>


